package net.huashitong.supervision.gongjian.dao;

import com.sirdc.modules.core.dao.GenericQuery;
import com.sirdc.modules.core.dao.StringDao;
import com.sirdc.modules.utils.StringUtils;
import net.huashitong.supervision.gongjian.entity.project.KaiGongEntity;
import net.huashitong.supervision.gongjian.filter.KaiGongFilter;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class KaiGongDao extends StringDao<KaiGongEntity> {



    public List<KaiGongEntity> getListNopage(KaiGongFilter filter)
    {
        GenericQuery query =createQuery("obj");
        return query.listResult();

    }
    /**
     *
     * @param filter
     * @return
     */
    public List<KaiGongEntity> getList(KaiGongFilter filter)
    {
        GenericQuery query =createQuery("obj");
        return query.listResult(filter);

    }

    public List<KaiGongEntity> getListForOwn(KaiGongFilter filter)
    {

        String hql = "select z " +
                "     from  KaiGongEntity as z ,GjDeptProject as g " +
                "      where z.sysId=g.projectId ";
        GenericQuery query =create(hql);
        if(StringUtils.isNotBlank(filter.getDeptId()))
        {
            query.append(" and g.deptId=:deptId").setParam("deptId",filter.getDeptId());
        }
        query.append(" and g.projectType=:projectType").setParam("projectType",filter.getProjectType());


        return query.listResult(filter);

    }
}
